#include <QCoreApplication>
#include <vector>
#include <iostream>
#include <set>
using namespace std;
class OneHandScheduling
{
public:
    string checkSchedule(vector <int> tStart, vector <int> tEnd)
    {
        set<int> value;
        string result="Possible";
        pair<set<int>::iterator,bool> ret;
        for(int i=0;i<tStart.size();i++)
        {
            for (int j=tStart[i];j<=tEnd[i];j++)
           {
                ret=value.insert(j);
                if (!ret.second)
                {
                  result="Impossible";
                  break;
                }
            }
            if(result=="Impossible")
                break;
        }
        return result;
    }
};
class EllysAndXor
{
public:
    int getMax(vector <int> numbers)
    {
        int ans=0;
        vector<int> storage;
        storage.push_back(numbers[0]);
        for(int i=1;i<numbers.size();i++)
        {
            int ccc,ddd;
            ccc=1<<i;
            ddd=1<<(i-1);
            for(int j=ddd-1;j<ccc-1;j++)
            {
            storage.push_back(storage[j] & numbers[i]);
            storage.push_back(storage[j] ^ numbers[i]);
            }
        }
        int b;
        b=(1<<numbers.size())-(1<<(numbers.size()-1));
        for(int i=storage.size()-1;i>int(storage.size())-b-1;i--)
            ans=max(ans,storage[i]);
        return ans;
    }



int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
//    OneHandScheduling test;
//    vector<int> start{10, 400000, 500000},end{20, 600000, 700000};
//    cout<<test.checkSchedule(start,end);
    EllysAndXor test;
    vector <int> numbers{123};
    cout<<test.getMax(numbers);
    return a.exec();
}
